using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebSMS
{
    public partial class SMSRetorno : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string senha = Request["senha"].ToString();
            string urlCripto = Request["url"].ToString();
            string path = Request.PhysicalApplicationPath + "message.txt";
            senha = Tools.cryp.Cryptografia.Desencriptar(senha, Tools.cryp.Crypto.TipoChave.Password);
            urlCripto = Tools.cryp.Cryptografia.Desencriptar(urlCripto, Tools.cryp.Crypto.TipoChave.Password);
            string[] valors = urlCripto.Split(';');
            string message = valors[1];
            string celular = valors[0];
            string link = "";
            if (celular.Substring(0, 2) != "55")
            {
                celular = "55" + celular;
            }
            link = Tools.clsDefault.LerTxt(path);
            link = link.Replace("@@message@@", message);
            link = link.Replace("@@celular@@", celular);

            if (senha == "lopesAutorizado" + DateTime.Today.Hour.ToString())
            {
                Response.Redirect(link);
                try
                {
                    Tools.Web.TakeSite Tsite = new Tools.Web.TakeSite();
                    string conteudo = Tsite.CapturaHtml(link);
                }
                catch
                {

                }
            }
            
        }
    }
}
